import 'package:dio/dio.dart';
import 'package:shop/app_config.dart';

///上传图片至校内图床
upload(String path,[String token=AppConfig.imageUploadToken]) async {
  BaseOptions baseOptions = BaseOptions(
    baseUrl: AppConfig.imageBaseUrl,
  );
  FormData data = FormData.fromMap({
    "token": token,
    "image": MultipartFile.fromFileSync(path)
  });
  var dio = Dio(baseOptions);
  Response res = await dio.post(
    '/api/index.php',
    data: data,
  );
  return res.data as Map;
}